package bishi.meituan;

import java.util.Scanner;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/05/09 11:06
 */
public class Main3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        sc.nextLine();
        while (t>0){
            int x = sc.nextInt();
            int a = sc.nextInt();
            int b = sc.nextInt();
            int n = sc.nextInt();
            sc.nextLine();
            t--;
            int ah = (b*n+x+a/2)/(2*b+a);
            int bh = n-ah;
            System.out.println(ah);
            System.out.println(bh*(b*ah+x)-(bh*bh-bh)*a/2);
        }
    }
}
